m.controller("accountcontroller",function($rootScope,$scope) {
	
$scope.init = function(){	
	if($rootScope.userOfLoger!=null&&$rootScope.userOfLoger!=""){
		
	$.ajax({
            type:"POST",
            url:"/selled/getSelledByUserName",
            data:{"userName":$rootScope.userOfLoger},
            contentType:"application/x-www-form-urlencoded",
            dataType:"json",
            success:function(data){
            	 $scope.$apply(function(){
                     $scope.selled = new Array();
                     var obj = {};
                     for(var temp in data.value){
                    	 $scope.totalPrice = $scope.totalPrice+data.value[temp].price*parseInt(data.value[temp].number);
                    	 obj['pic'] = data.value[temp].commodity.picture;
                    	 
                         obj['name'] = data.value[temp].commodity.name;

                         obj['number'] = data.value[temp].number;
                         obj['price'] = data.value[temp].price;
                          var datestr = new Date(parseInt(data.value[temp].time));
                         var temstr = datestr.getFullYear() + "年" + (parseInt(datestr.getMonth())+1) + "月" + datestr.getDate() + "日"
                             + datestr.getHours() + ":" + datestr.getMinutes() + ":" + datestr.getSeconds()
                             ;
                         obj['time'] = temstr;	//创建时间
                         $scope.selled.push(obj);obj = {};
                     }
                 });
            		
            	}
            		
            	});

	}
		
	}
$scope.htmlInit = function(){
	
	$.ajax({
        type:"POST",
        url:"/login/getSession",
        contentType:"application/x-www-form-urlencoded",
        dataType:"json",
        success:function(data){
            if(data.value!=null){
            	$rootScope.userOfLoger = data.value;

            	$scope.init();         	
            }else{
            	$rootScope.userOfLoger = null;
            }
            $scope.$apply();
        }
	});
	
}
$scope.totalPrice = 0;
$scope.htmlInit();
    
});